home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GETX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  849 b   |  30 lines

  1. /*   getx  */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <graphics.h>
  5.  
  6. main()
  7. {
  8.     int graphdriver = DETECT, graphmode;
  9.     int oldx,oldy;
  10.     char buffer[80];
  11.  
  12. /* Initialize the graphics system  */
  13.     initgraph(&graphdriver,&graphmode,"c:\\turboc");
  14.     outtextxy(10,20,"Demonstrating getx and gety");
  15. /* Draw random polygons with three vertices */
  16.     randomize();
  17.     moveto(random(getmaxx()),random(getmaxy()));
  18. /* Save first point ot close the figure */
  19.     oldx =getx();
  20.     oldy =gety();
  21. /* Draw two line segments */
  22.     lineto(random(getmaxx()),random(getmaxy()));
  23.     lineto(random(getmaxx()),random(getmaxy()));
  24. /* Now draw a line to first point to close to close figure */
  25.     lineto(oldx,oldy);
  26. /* Give user a chance to see the result */
  27.     outtextxy(10,270,"Hit any key to exit:");
  28.     getch();
  29.     closegraph();  /* Close graphics system */
  30. }